package com.gamerole.app.ui

import androidx.fragment.app.Fragment
import androidx.fragment.app.viewModels
import androidx.lifecycle.MutableLiveData
import androidx.viewpager2.adapter.FragmentStateAdapter
import com.gamerole.app.R
import com.gamerole.app.databinding.AppFragmentChatBinding
import com.gamerole.app.entity.ArticleBean
import com.gamerole.app.viewmodel.ChatViewModel
import com.gamerole.commom.adapter.MyFragmentPagerAdapter
import com.gamerole.commom.base.BaseFragment
import com.google.android.material.tabs.TabLayoutMediator
import com.hi.dhl.binding.viewbind
import dagger.hilt.android.AndroidEntryPoint
import java.util.*


@AndroidEntryPoint
class ChatFragment : BaseFragment(R.layout.app_fragment_chat) {
    private val viewModelChat: ChatViewModel by viewModels()
    override fun getViewModel() = viewModelChat
    private val binding: AppFragmentChatBinding by viewbind()

//    override fun initStatusNavBar() {
//        ImmersionBar.with(this)
//            .fitsSystemWindows(false)
//            .fullScreen(true)
//            .transparentNavigationBar()
//            .init()
//    }

    override fun initData() {

    }

    override fun initView() {
        var fragments = ArrayList<Fragment>()
        for (i in 1..5) {
            fragments.add(
                ArticleFragment(i)
            )
        }
        binding.viewPager.offscreenPageLimit = 1
        binding.viewPager.adapter = object : FragmentStateAdapter(childFragmentManager, lifecycle) {
            override fun getItemCount(): Int {
                return fragments.size
            }

            override fun createFragment(position: Int): Fragment {
                return fragments[position]
            }
        }
        var titles=arrayListOf("动漫","电影","电视剧","国漫","经典电视剧")
        TabLayoutMediator(binding.tabLayout, binding.viewPager) { tab, position ->
            tab.text = titles[position]
        }.attach()
    }


}